package design.donkey.auto.ddl.dialect.mysql.handler;

import design.donkey.auto.ddl.model.ColumnMetaModel;

/**
 * 0 填充处理处理
 * 
 * @since 0.0.1
 * @author zhangjiakung
 */
public class ColumnHandlerForZerofill implements ColumnHandler {
    @Override
    public String handle(ColumnMetaModel columnMetaModel) {
        boolean zerofill = columnMetaModel.isZerofill();
        if (!zerofill) {
            return null;
        }
        return switch (columnMetaModel.getJdbcType()) {
            case TINYINT, SMALLINT, MEDIUMINT, INT, BIGINT -> columnMetaModel.getLength() == 0 ? null : "zerofill";
            case DECIMAL -> "zerofill";
            default -> null;
        };
    }
}
